﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using YJKSparseDistance;
using YJKSparseDistance.ControlLayer;
using YJKSparseDistance.ModelLayer;
using YJKRoomInspection.ProgramArchitecture;
using YJKRoomInspection.Utiltiy;
using YArchitech.Controls;
using YJKInspectModelFunc.ControlLayer;
using YJKInspectModelFunc.ModelLayer;

namespace YJKSparseDisOfDoor.ControlLayer
{
	public class AppendCheckArch : IFlowYJKRoomInspection
	{
		private List<RoomPacker_EvacuationDistance> GetAllRunWayRoom()
		{
			Document document = StaticRescource.CmdData.Application.ActiveUIDocument.Document;
			List<Level> selectLevels = StaticRescource.m_SelectLevels;
			List<ICloseCurveAnalays> frontRoomData = EvacuationDistanceArch.GetFrontRoomData(StaticRescource.CmdData.Application.ActiveUIDocument, selectLevels);
			List<BaseRoomPacker> list = new List<BaseRoomPacker>();
			foreach (KeyValuePair<int, BaseElementPacker> keyValuePair in ElementPackerManger.DicNowValues)
			{
				if (keyValuePair.Value is BaseRoomPacker)
				{
					list.Add(keyValuePair.Value as BaseRoomPacker);
				}
			}
			return YJKSparseDistance.Utility.FindAllRunWayRooms(list, frontRoomData, false);
		}

		public void CheckMethod()
		{
			EvacuationDoorDistance evacuationDoorDistance = new EvacuationDoorDistance(this.GetAllRunWayRoom());
			if (!evacuationDoorDistance.YJKSparseDisOfDoor())
			{
				return;
			}
			if (evacuationDoorDistance.LstAllResult.Count > 0)
			{
				ResultForm inputForm = new ResultForm(evacuationDoorDistance, StaticRescource.m_hWndRevit, StaticRescource.CmdData.Application.ActiveUIDocument);
				new LoopMangerNoneSwitch_EvacuationDoorDisDetection(StaticRescource.CmdData.Application.ActiveUIDocument, inputForm, null, null).DoLoopWork();
				return;
			}
			YJKMessageBox.Show("您所检测的楼层中，房间疏散门间距全部满足规范要求！");
		}
	}
}
